<?php

/**
 * GetApi.class.php 获取文章详情
 * 
 *
 * @author     late.xiao@qq.com
 */
namespace Sysblog\Api;

use Base\Lib\Implement\Api;

class GetApi implements Api {

    /**
     * @var string
     * */
    public $api_desc = '获取文章详情';
    public function getParams()
    {
        $params = array(
                'aid'=>array('type'=>'int', 'valid'=>'required', 'default'=>'', 'title'=>'文章ID'),
                'fields'=>array('type'=>'string', 'valid'=>'', 'default'=>'*', 'title'=>'所返回的字段')
        );
        
        return $params;
    }
    
    public function getInfo($params)
    {
        if(!$params['aid'])
        {
            return false;
        }
        
        $aid = intval($params['aid']);
        $field = '*';
        if($params['fields'])
        {
            $field = $params['fields'];
        }
        
        $obj_serv = D('Sysblog/Article','Service');
        
        $data = $obj_serv->getRow($aid, $field);
        
        return $data;
    }

}
 
 